package com.rjpacket.supernews.app.model;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by WIN7 on 2015/3/10.
 */
public class Duanzi implements Serializable {

    private String[] thumbs;
    private int nmark;
    private int db;
    private int bad_num;
    private long stime;
    private long nid;
    private int evaluated;
    private int itype;
    private String content;
    private String title;
    private long time;
    private String source;
    private int good_num;
    private int comment_num;
    private boolean collect;

    private DuanziDetail duanziDetail;

    public DuanziDetail getDuanziDetail() {
        return duanziDetail;
    }

    public void setDuanziDetail(DuanziDetail duanziDetail) {
        this.duanziDetail = duanziDetail;
    }

    private List<Duanzi> list;

    public List<Duanzi> getList() {
        return list;
    }

    public void setList(List<Duanzi> list) {
        this.list = list;
    }

    public void parseJSON(JSONObject jsonObject) {
        if (jsonObject != null) {
            list = new LinkedList<Duanzi>();
            try {
                JSONArray news = jsonObject.getJSONArray("news");
                for (int i = 0; i < news.length(); i++) {
                    Duanzi duanzi = duanzi = new Duanzi();
                    JSONObject duanziItem = news.getJSONObject(i);

                    //将从json中获得的数据赋值给段子
                    duanzi.setContent(duanziItem.getString("content"));
                    duanzi.setGood_num(duanziItem.getInt("good_num"));
                    duanzi.setBad_num(duanziItem.getInt("bad_num"));
                    duanzi.setComment_num(duanziItem.getInt("comment_num"));
                    duanzi.setNid(duanziItem.getLong("nid"));

                    list.add(duanzi);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }


    public String[] getThumbs() {
        return thumbs;
    }

    public void setThumbs(String[] thumbs) {
        this.thumbs = thumbs;
    }

    public int getNmark() {
        return nmark;
    }

    public void setNmark(int nmark) {
        this.nmark = nmark;
    }

    public int getDb() {
        return db;
    }

    public void setDb(int db) {
        this.db = db;
    }

    public int getBad_num() {
        return bad_num;
    }

    public void setBad_num(int bad_num) {
        this.bad_num = bad_num;
    }

    public long getStime() {
        return stime;
    }

    public void setStime(long stime) {
        this.stime = stime;
    }

    public long getNid() {
        return nid;
    }

    public void setNid(long nid) {
        this.nid = nid;
    }

    public int getEvaluated() {
        return evaluated;
    }

    public void setEvaluated(int evaluated) {
        this.evaluated = evaluated;
    }

    public int getItype() {
        return itype;
    }

    public void setItype(int itype) {
        this.itype = itype;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public int getGood_num() {
        return good_num;
    }

    public void setGood_num(int good_num) {
        this.good_num = good_num;
    }

    public int getComment_num() {
        return comment_num;
    }

    public void setComment_num(int comment_num) {
        this.comment_num = comment_num;
    }

    public boolean isCollect() {
        return collect;
    }

    public void setCollect(boolean collect) {
        this.collect = collect;
    }
}
